package com.hmall.feign.clients;

import com.hmall.feign.dto.PageDTO;
import com.hmall.feign.pojo.Item;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "itemservice")
public interface ItemClient {

    @GetMapping("/item/{id}")
    Item getById(@PathVariable(name = "id")Long id);

    @GetMapping("/item/list")
    public PageDTO<Item> list(@RequestParam(name="page") Integer page,
                                @RequestParam(name="size")Integer size);

    /**
     * 根据商品id和购买数量修改库存数量
     * @param itemId
     * @param num
     */
    @PostMapping("/item/stock/{itemId}/{num}")
    public void updateStock(@PathVariable(name = "itemId")Long itemId
            ,@PathVariable(name = "num")Integer num);

    /**
     * 恢复库存
     * @param itemId
     * @param num
     */
    @PostMapping("/item/restoreStock/{itemId}/{num}")
    public void restoreStock(@PathVariable(name = "itemId")Long itemId
            ,@PathVariable(name = "num")Integer num);

}
